package ma.ensao.egicom.dao.implementations;

import java.util.List;

import ma.ensao.egicom.core.model.Marketorderline; 
import ma.ensao.egicom.dao.interfaces.MarketorderlineDAO;

import org.hibernate.Query;
import org.scub.foundation.framework.core.dao.implementations.HibernateDaoBaseImplementation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MarketorderlineDAOImpl extends HibernateDaoBaseImplementation implements MarketorderlineDAO {

    
    private static final Logger log = LoggerFactory
            .getLogger(MarketorderlineDAO.class);
    // property constants
    public static final String QUANTITY = "quantity";

    /**
     * {@inheritDoc}
     */
    @Override
    public void save(Marketorderline transientInstance) {
        save(transientInstance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void delete(Marketorderline persistentInstance) {
        delete(persistentInstance);
        
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    public Marketorderline findById( java.lang.Integer id) {
        return load(id, Marketorderline.class);
    }

    
    /**
     * {@inheritDoc}
     */
    @Override
    public List findByProperty(String propertyName, Object value) {
        log.debug("finding Marketorderline instance with property: "
                + propertyName + ", value: " + value);
        try {
            String queryString = "from Marketorderline as model where model."
                    + propertyName + "= ?";
            Query queryObject =  createQuery(queryString);
            queryObject.setParameter(0, value);
            return queryObject.list();
        } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
        }
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public List findByQuantity(Object quantity) {
        return findByProperty(QUANTITY, quantity);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public List findAll() {
        return loadAll(Marketorderline.class);
    }
 
}